from enum import Enum


class State(Enum):
    ONLINE = 1
    OFFLINE = 2


class DeviceState(object):
    def __init__(self) -> None:
        self.device_state = {}

    def online(self, id):
        self.device_state[id] = State.ONLINE

    def offline(self, id):
        self.device_state[id] = State.OFFLINE

    def state(self, id):
        try:
            return self.device_state[str(id)].value
        except Exception:
            return State.OFFLINE.value


global deviceState
deviceState = DeviceState()
